//
//  EditSignedApi.m
//  EMMApp
//
//  Created by YangLiang on 16/5/26.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "EditSignedApi.h"
#define myUrlMethod @"editSigned"
#define myUrlPath @"/appapi/editSigned"

@implementation EditSignedApi
{
    NSString *_body;
}

- (instancetype)initWithPayDepositId:(NSString *)payDepositId
                      payDepositCode:(NSString *)payDepositCode
                     payDepositMoney:(NSString *)payDepositMoney
                         subscribeId:(NSString *)subscribeId
                       subscribeCode:(NSString *)subscribeCode
                     subscribeAmount:(NSString *)subscribeAmount
                            signedId:(NSString *)signedId
                        signedHouses:(NSString *)signedHouses
                       calculateArea:(NSString *)calculateArea
                       discountPrice:(NSString *)discountPrice
                  discountTotalPrice:(NSString *)discountTotalPrice
                      discountAmount:(NSString *)discountAmount
                        discountRate:(NSString *)discountRate
                    discountApproval:(NSString *)discountApproval
                 preferentialReasons:(NSString *)preferentialReasons
                        discountNote:(NSString *)discountNote
                       contractPrice:(NSString *)contractPrice
                      contractAmount:(NSString *)contractAmount
                        dealCategory:(NSString *)dealCategory
                             agentId:(NSString *)agentId
                          signedDate:(NSString *)signedDate
                          signedCode:(NSString *)signedCode
                              remark:(NSString *)remark
                         auditStatus:(NSString *)auditStatus
                        customerName:(NSString *)customerName
                        documentType:(NSString *)documentType
                      documentNumber:(NSString *)documentNumber
                              mobile:(NSString *)mobile
                            mailPost:(NSString *)mailPost
                            postcode:(NSString *)postcode
                       paymentMethod:(NSString *)paymentMethod
                   paymentMethodList:(NSMutableArray *)paymentMethodList
                           imageList:(NSMutableArray *)imageList
                  customerFamilyList:(NSMutableArray *)customerFamilyList
                           floorType:(NSString *)floorType
                 discountAfterAmount:(NSString *)discountAfterAmount
                    dealCategoryList:(NSMutableArray *)dealCategoryList
                         referenceId:(NSString *)referenceId
                       referenceName:(NSString *)referenceName
                 referenceProportion:(NSString *)referenceProportion
                          memberName:(NSString *)memberName fixHouseMethod:(NSString *)method methodList:(NSArray *)methodList decorationMoney:(NSString *)decorationMoney{
    self = [super init];
    if (self) {
        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
        NSString *merchantId = [userdf objectForKey:@"merchantId"];
        NSString *userId = [userdf objectForKey:@"userNameId"];
        NSString *token = [userdf objectForKey:@"is_login"];
        NSString *projectCode = [userdf objectForKey:@"projectCode"];
        
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        [params setValue:apiVersion forKey:@"version"];
        [params setValue:[IDTools devId2] forKey:@"terminalCode"];
        [params setValue:merchantId forKey:@"merchantId"];
        [params setValue:userId forKey:@"userId"];
        [params setValue:token forKey:@"token"];
        [params setValue:projectCode forKey:@"projectCode"];
        [params setValue:signedId forKey:@"signedId"];
        [params setValue:payDepositId forKey:@"payDepositId"];
        [params setValue:payDepositCode forKey:@"payDepositCode"];
        [params setValue:payDepositMoney forKey:@"payDepositMoney"];
        [params setValue:subscribeId forKey:@"subscribeId"];
        [params setValue:subscribeCode forKey:@"subscribeCode"];
        [params setValue:subscribeAmount forKey:@"subscribeAmount"];
        [params setValue:signedHouses forKey:@"signedHouses"];
        [params setValue:calculateArea forKey:@"calculateArea"];
        [params setValue:discountPrice forKey:@"discountPrice"];
        [params setValue:discountTotalPrice forKey:@"discountTotalPrice"];
        [params setValue:discountAmount forKey:@"discountAmount"];
        [params setValue:discountRate forKey:@"discountRate"];
        [params setValue:discountApproval forKey:@"discountApproval"];
        [params setValue:preferentialReasons forKey:@"preferentialReasons"];
        [params setValue:discountNote forKey:@"discountNote"];
        [params setValue:contractPrice forKey:@"contractPrice"];
        [params setValue:contractAmount forKey:@"contractAmount"];
        [params setValue:dealCategory forKey:@"dealCategory"];
        [params setValue:agentId forKey:@"agentId"];
        [params setValue:signedDate forKey:@"signedDate"];
        [params setValue:signedCode forKey:@"signedCode"];
        [params setValue:remark forKey:@"remark"];
        [params setValue:auditStatus forKey:@"auditStatus"];
        [params setValue:customerName forKey:@"customerName"];
        [params setValue:documentType forKey:@"documentType"];
        [params setValue:documentNumber forKey:@"documentNumber"];
        [params setValue:mobile forKey:@"mobile"];
        [params setValue:mailPost forKey:@"mailPost"];
        [params setValue:postcode forKey:@"postcode"];
        [params setValue:paymentMethod forKey:@"paymentMethod"];
        [params setValue:paymentMethodList forKey:@"paymentMethodList"];
        [params setValue:imageList forKey:@"imageList"];
        [params setValue:customerFamilyList forKey:@"customerFamilyList"];
        [params setValue:floorType forKey:@"floorType"];
        [params setValue:discountAfterAmount forKey:@"discountAfterAmount"];
        [params setValue:dealCategoryList forKey:@"dealCategoryList"];
        [params setValue:referenceId forKey:@"referenceId"];
        [params setValue:referenceName forKey:@"referenceName"];
        [params setValue:referenceProportion forKey:@"referenceProportion"];

        // 新增装修款
        [params setValue:methodList forKey:@"decorationPaymentMethodList"];
        [params setValue:method forKey:@"decorationPaymentMethod"];
        [params setValue:decorationMoney forKey:@"decorationMoney"];
        
        [params setValue:memberName forKey:@"memberName"];

        _body = [@{@"params" : params} JSONString];
        NSLog(@"%@:\n %@%@?body=%@", myUrlMethod, apiBaseUrl, myUrlPath, _body);
    }
    return self;
}

#pragma mark - 父类继承拓展

- (NSString *)requestUrl
{
    return myUrlPath;
}

- (id)requestArgument
{
    return @{ @"body" : _body };
}

- (NSString *)methodString
{
    return myUrlMethod;
}


#pragma mark - 通用

- (EditSigned *)resultData
{
    id myObj = [IDTools jsonStrToObjc:self.responseString method:myUrlMethod];
    
    EditSigned *data = (EditSigned *)myObj;
    
    NSLog(@"%@ resultData is %@", myUrlMethod, data);
    
    return data;
}

- (BOOL)isSuccess
{
    NSString *str = [[self resultData] result];
    if ([NSString isStringEmpty:str] || ![str isEqualToString:@"1"]) {
        return NO;
    } else {
        return YES;
    }
}


@end
